#ifndef __CONTROL_H_
#define __CONTROL_H_



typedef struct
{
    float Expect;
    float ErrorMaxLimit;
    float ErrorMinLimit;
    float KP;
    float KI;
    float KD;
    float BaseKP;
    float BaseKI;
    float BaseKD;
	  float BaseKP_R;
	  float BaseKI_R;
    float Error;
    float ErrorFifo[5];
    float ErrorLast;
    float ErrorDtFifo[5];
    float ErrorTemp[4];
    float ErrorDtTemp[4];
    float InOut;
    float Integ;
    float OutPut;
    float OutPutMaxLimit;
    float OutPutMinLimit;
    float RampKP;
    float RampKD;
}StandInfotypedef;

typedef struct
{

    float InnerInput;
    float Count;
    float BaseKP;
    float BaseKD;
    float CirKp;
    float KP;
    float KI;
    float KD;
    float KP_1;
    float KD_1;
    float ErrorKP;
    float ErrorDtTemp[4];
    float ErrorFifo[20];
    float OutPut;
    float OutPutOld;
    float OutPutNew;
    float Turn_Yaw;
    float CirKP;
    float CirKD;
    float RampKP;
    float HengDuanKP;
    float CirOut;
    float CirOutPut;
    float CirOutTemp[4];
    float Expect_Curvature;
    float Expect_Curvature_last;
    float Expect_Curvature_dec;
    float Curvature_Input[8];
    float Curvature_Output[8];
    float Curvature_Final;
    float Curvature_Correct;
}DirOutterInfotypedef;

typedef struct
{
    float KP;
    float KI;
    float KD;
    float KD_1;
    float BaseKP;
    float BaseKI;
    float BaseKD;
    float Error;
    float ErrorFifo[10];
    float ErrorLast;
    float ErrorDt;
    float feedback[10];
    float ErrorTemp[4];
    float ErrorDtTemp[4];
    float FeedbackTemp[4];
    float Differential;
    float InOut;
    float Integ;
    float OutPut;
    float OutTemp[4];
    float SpeedRatio;
}DirInnerInfotypedef;

extern float SpeedControl,SpeedControl_R;
extern float FloatRangeProtect(float data1, float max_out, float min_out);
extern float speed_stan;

extern StandInfotypedef SpeedLoop,GyroLoop,AngelLoop;
extern DirOutterInfotypedef DirOutter;
extern DirInnerInfotypedef DirInner;
extern float Direction_Out;
extern float direction[4];

void Speed_Loop(void);
void PID_Init();
void Direction_Inner(void);
void Direction_Outter(void);
float FloatRangeProtect(float data1, float max_out, float min_out);

#endif